package danny.hoi.web.controller.system;

import com.github.pagehelper.PageInfo;
import danny.hoi.domain.export.system.SysLog;
import danny.hoi.domain.export.system.SysLogExample;
import danny.hoi.service.export.system.SysLogService;
import danny.hoi.web.controller.base.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/system/log")
public class SysLogController extends BaseController {

    @Autowired
    private SysLogService sysLogService;

    /**
     * 查询日志
     * 请求地址： /system/log/list.do
     * 响应地址：WEB-INF/pages/system/log/log-list.jsp
     */
    @RequestMapping("/list")
    public String list(@RequestParam(defaultValue = "1") Integer pageNum,
                       @RequestParam(defaultValue = "5") Integer pageSize) {
        SysLogExample example = new SysLogExample();
        SysLogExample.Criteria criteria = example.createCriteria();
        criteria.andCompanyIdEqualTo(getLoginCompanyId());
        example.setOrderByClause("time desc");
        PageInfo<SysLog> pageInfo = sysLogService.findByPages(example, pageNum, pageSize);
        request.setAttribute("pageInfo", pageInfo);
        return "system/log/log-list";
    }
}
